package yxy.game.pm2.module.battle;

import yxy.game.pm2.message.BattleMessage;

abstract public class BattleModuleHandle {

	abstract protected String code();

	/** 获取进行中的战斗数据 */
	public BattleMessage.BattlePlayBack getBattling(String playerCode) {
		BattleModule module = BattleModule.get(playerCode, code());
		if (module == null || !module.isFinished() || module.isSettled()) {
			return null;
		}
		return new BattleHandle().playback(module);
	}

	/** 还在战斗中 */
	public boolean isBattling(String playerCode) {
		BattleModule module = BattleModule.get(playerCode, code());
		if (module == null) {
			return false;
		}
		return isBattling(module);
	}

	public boolean isBattling(BattleModule module) {
		return module.battling();
	}

}
